package router

import (
	"enjoy-shop/api/cart"
	api2 "enjoy-shop/api/comment"
	coupon3 "enjoy-shop/api/coupon"
	"enjoy-shop/api/goods"
	"enjoy-shop/api/integral"
	order2 "enjoy-shop/api/order"
	"enjoy-shop/api/public"
	"enjoy-shop/api/spikes"
	"enjoy-shop/api/user"
	"github.com/gin-gonic/gin"
)

func Router(r *gin.Engine) {

	s := r.Group("/spikes")
	{
		s.POST("/create/activity", spikes.CreateSpikesActivity)  //活动创建
		s.POST("/create/goods_sku", spikes.CreateSpikesGoodsSku) // 创建参与活动的商品
		s.POST("/activity/list", spikes.GetSpikesActivityList)   //活动列表
		s.POST("/goods/info", spikes.GetSpikesGoodsInfo)         //查询商品信息
		s.POST("/goods/list", spikes.GetSpikesGoodsList)         //活动商品列表
		o := s.Group("/order")
		{
			o.POST("/create", spikes.CreateOrder) // 秒杀订单创建
		}
	}
	i := r.Group("/integral")
	i.Use(user.MiddleWare())
	{
		i.POST("/create", integral.CreateIntegralRecord)
		i.POST("/list", integral.GetIntegralRecordList)
		i.POST("/get", integral.GerINtegralInfo)

	}
	order := r.Group("/order")
	{
		order.POST("/create", order2.OrderCreate) // 订单创建
	}
	c := r.Group("/cart")
	c.Use(user.MiddleWare())
	{
		c.POST("/create", cart.CreateGoodsCart)
		c.POST("/delete", cart.DeleteGoodsCart)
		c.POST("/update", cart.UpdateGoodsCartQuantity)
		c.POST("/list", cart.GetGoodsCartList)
	}
	g := r.Group("/goods")
	{
		g.POST("/get", goods.GetGood)
		g.POST("/search", goods.SearchGoods)
		g.POST("/get/part/info", goods.GetSkuInfoByPVIDs)
		g.POST("/list", goods.GoodList)
	}
	comment := r.Group("/comment")
	{
		comment.POST("/add", api2.AddComment)
		comment.POST("/del", api2.DelComment)
		comment.POST("/get", api2.GetCommentList)
		comment.POST("/getOrder", api2.GetOrderById)
		comment.POST("/getnum", api2.GetCommentNumByRat)
		comment.POST("/like", api2.CommentLike)
	}
	file := r.Group("/file")
	{
		file.POST("/adds", public.AddFile)
	}
	users := r.Group("/user")
	users.Use(user.MiddleWare())
	{
		users.POST("/update", user.Update)
		users.POST("/checkcode", user.CheckCode)
	}
	r.POST("/user/login", user.Login)
	r.POST("/user/sendcode", user.SendCode)
	r.POST("/user/register", user.UserRegister)
	coupon := r.Group("/coupon")
	{
		coupon.POST("/user/center/coupon/list", coupon3.UserCenterCouponList)
		coupon.POST("/goods/order/coupon/list", coupon3.GoodsOrderCouponList)
		coupon.POST("/member/list", coupon3.MemberList)
		coupon.POST("/points/list", coupon3.PointsList)
		coupon.POST("/points/info", coupon3.PointsInfo)
	}
}
